package ecom.beans;

import java.io.Serializable;
import java.util.Set;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author Morpheus
 */
@Entity
@Table(name = "productcategory")
@NamedQueries({
    @NamedQuery(name = "ProductcategoryBean.findAll", query = "SELECT p FROM ProductcategoryBean p"),
    @NamedQuery(name = "ProductcategoryBean.findByIdProductcategory", query = "SELECT p FROM ProductcategoryBean p WHERE p.idProductcategory = :idProductcategory"),
    @NamedQuery(name = "ProductcategoryBean.findByName", query = "SELECT p FROM ProductcategoryBean p WHERE p.name = :name")})
public class ProductcategoryBean implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "idProductcategory", nullable = false)
    private Long idProductcategory;
    @Basic(optional = false)
    @Column(name = "name", unique = true, nullable = false, length = 50)
    private String name;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idProductCategory")
    private Set<ProductBean> productBeanSet;

    public ProductcategoryBean() {
    }

    public ProductcategoryBean(Long idProductcategory, String name) {
        this.idProductcategory = idProductcategory;
        this.name = name;
    }

    public ProductcategoryBean(String name) {
        this.name = name;
    }

    public Long getIdProductcategory() {
        return idProductcategory;
    }

    public void setIdProductcategory(Long idProductcategory) {
        this.idProductcategory = idProductcategory;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Set<ProductBean> getProductBeanSet() {
        return productBeanSet;
    }

    public void setProductBeanSet(Set<ProductBean> productBeanSet) {
        this.productBeanSet = productBeanSet;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idProductcategory != null ? idProductcategory.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ProductcategoryBean)) {
            return false;
        }
        ProductcategoryBean other = (ProductcategoryBean) object;
        if ((this.idProductcategory == null && other.idProductcategory != null) || (this.idProductcategory != null && !this.idProductcategory.equals(other.idProductcategory))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "[idProductcategory=" + idProductcategory + ",name=" + name + "]";
    }
}
